﻿@model ProductCategory

<tr class="item-container" id="@string.Format("container{0}",Model.Id)">

    <td>
        @if (Model.ChildCategories.Any())
        {
        <a href="#" class="open" data-for="@Model.Id">
            <i class="fa fa-plus-circle"></i>
        </a>
        }
        else
        {
            <span style="display:inline-block;width:13px;height:12px;"></span>
        }
        @Model.Title
    </td>
    <td>
        @Model.SeoName
    </td>
    <td>
        @Model.Importance
    </td>

    <td>
        @if (Model.Active)
            {
            <a href="#" data-url="@Url.Action("IsActive", new {id = Model.Id})" class="active-item" title="激活" data-action="锁定">
                <i class="fa fa-check text-success"></i>
            </a>

        }
        else
        {
            <a href="#" data-url="@Url.Action("IsActive", new {id = Model.Id})" class="active-item" title="锁定" data-action="激活">
                <i class="fa fa-remove text-danger"></i>
            </a>
        }
    </td>

    <td>
        @Ajax.RawActionLink("<i class='fa fa-edit'></i>",
                        "Edit", "ProductCategory",
                        new { id = Model.Id },
                        new AjaxOptions { HttpMethod = "Get", UpdateTargetId = "edit-container", OnComplete = "onAjaxComplete", OnSuccess = "OnSuccessLink" },
                        new { @class = "btn btn-primary btn-sm", title = Buttons.Edit })

        <a href="#" data-url="@Url.Action("Delete", new {id = Model.Id})" class="btn btn-danger btn-sm delete-item" title="@Buttons.Delete">
            <i class="fa fa-trash-o"></i>
        </a>
    </td>
</tr>

    @if (Model.ChildCategories.Any())
    {
        
            foreach (var item in Model.ChildCategories)
            {
                <tr class="item-container subItem" style="background-color:#f1f1f1;" id="@string.Format("container{0}",item.Id)" data-parent="@item.ParentId">
                    <td>
                        ∟ @item.Title
                    </td>
                    <td>
                        @item.SeoName
                    </td>
                    <td>
                        @item.Importance
                    </td>

                    <td>
                        @if (item.Active)
                        {
                            <a href="#" data-url="@Url.Action("IsActive", new {id = item.Id})" class="active-item" title="激活" data-action="锁定">
                                <i class="fa fa-check text-success"></i>
                            </a>

                        }
                        else
                        {
                            <a href="#" data-url="@Url.Action("IsActive", new {id = item.Id})" class="active-item" title="锁定" data-action="激活">
                                <i class="fa fa-remove text-danger"></i>
                            </a>
                        }
                    </td>

                    <td>
                        @Ajax.RawActionLink("<i class='fa fa-edit'></i>",
                        "Edit", "ProductCategory",
                        new { id = item.Id },
                        new AjaxOptions { HttpMethod = "Get", UpdateTargetId = "edit-container", OnComplete = "onAjaxComplete", OnSuccess = "OnSuccessLink" },
                        new { @class = "btn btn-primary btn-sm", title = Buttons.Edit })

                        <a href="#" data-url="@Url.Action("Delete", new {id = item.Id})" class="btn btn-danger btn-sm delete-item" title="@Buttons.Delete">
                            <i class="fa fa-trash-o"></i>
                        </a>
                    </td>
                </tr>
            }

    }
